package com.doctor.adapter;

import java.util.List;

import com.doctor.ui.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SubMenuAdapter extends BaseAdapter{

	/**
	 * 主菜单下的子菜单adapter
	 */
	
	private Context context;
	private final String[] menu;
	//被选中的位置
	private int selectedPosition=0;
	//item宽高参数

	public SubMenuAdapter(Context context,String[] menu){
		this.context=context;
		this.menu=menu;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return menu.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
	
	public int getSelectedPosition() {
		return selectedPosition;
	}

	public void setSelectedPosition(int selectedPosition) {
		this.selectedPosition = selectedPosition;
		this.notifyDataSetChanged();
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		String menuName=menu[arg0];
		
		arg1=View.inflate(context, R.layout.sub_menu_item, null);
		
		if (selectedPosition==arg0) {
			arg1.setBackgroundResource(R.color.blue);
		} else {
			arg1.setBackgroundResource(R.color.light_blue);
		}
		
		TextView name=(TextView) arg1.findViewById(R.id.subMenuItem);
		name.setText(menuName);
		
		return arg1;
	}
	
	
}
